package pattern14.games;

/**
 * 游戏中的角色类
 * @author wdl
 */
public class Role {
    /**
     * 生命值
     * 攻击力
     * 防御力
     */
    private int vik;
    private int atk;
    private int def;

    public int getVik() {
        return vik;
    }

    public void setVik(int vik) {
        this.vik = vik;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }

    /**
     * 备份
     * @return 备份
     */
    public RoleStateMemento saveStateToMemento(){
        return new RoleStateMemento(vik,atk,def);
    }

    /**
     * 恢复备份
     * @param roleStateMemento 备份数据
     */
    public void getStateFromMemento(RoleStateMemento roleStateMemento){
        vik=roleStateMemento.getVik();
        atk=roleStateMemento.getAtk();
        def=roleStateMemento.getDef();
    }

    public void show(){
        System.out.println("vik:"+vik);
        System.out.println("atk:"+atk);
        System.out.println("def:"+def);
    }
}
